<?php
// admin users edit page
require_once 'view/adm/users/registered.index.php';
require_once 'control/adm/users/registered/form.php';

class RegisteredUsersDeactivatePage extends PageController {

	var $form;

    function RegisteredUsersDeactivatePage() {
        parent::PageController();
        $this->form =& new RegisteredUsersFormController();
        $this->registerOnLoadListener(new Delegate($this, 'load'));
        $this->addChild('UserForm', $this->form);
        $this->setDefaultChild('UserForm');


        //$listview =& new AdminUsersListView('/adm/users/administrators.index.html');
        $this->setDefaultView(new Handle('RegisteredUsersListView', array('/adm/users/registered.index.html')));
        //$listview =& new AdminUsersListView('/adm/users/test.html');
        //$this->addView('index', $listview);

        //$this->setDefaultView('index');

        $this->addView('success', WACT_DEFAULT_VIEW);
        $this->addView('notfound', WACT_DEFAULT_VIEW);


        $this->registerOnActivateListener(new Delegate($this, 'guard'));
   }

   function guard(&$source, &$request, &$responseModel) {
      if (!$request->hasParameter('user_id')) {
            return 'notfound';
        }
     }

     function load(&$source, &$request, &$responseModel) {
     	$login = $responseModel->get('login');
     	$this->form->deactivate($source, $request, $responseModel);
     	$responseModel->set('msg','The user '.$login.' has been deactivated!');
     	return 'success';
     }
}

?>